import string

def judge():
    chars = [set(v) for v in (string.digits, string.ascii_lowercase, string.ascii_uppercase, string.punctuation)]

    def _judge(src: str, length=8):
        val = set(src)
        level = 0
        if len(src) > length:
            for i in range(4):
                if val & chars[i]:
                    level += 1
        return level
    return _judge


fn = judge()
print(fn('1as1d$%fa'))